package com.register.client.common;

import lombok.Data;

@Data
public class ResultResponse {

    private Integer code;

    private String msg;

    private Object data;


    /**
     * 成功
     * @param data
     * @return
     */
    public static ResultResponse ofSuccess(Object data){
        ResultResponse  resultResponse = new ResultResponse();
        resultResponse.setCode(ResponseCode.SUCCESS.getCode());
        resultResponse.setMsg(ResponseCode.SUCCESS.getDesc());
        resultResponse.setData(data);
        return resultResponse;
    }
    /**
     * 失败
     * @param data
     * @return
     */
    public static ResultResponse ofFail(Object data){
        ResultResponse  resultResponse = new ResultResponse();
        resultResponse.setCode(ResponseCode.ERROR.getCode());
        resultResponse.setMsg(ResponseCode.ERROR.getDesc());
        resultResponse.setData(data);
        return resultResponse;
    }

    public static ResultResponse ofFail(String msg,Object data){
        ResultResponse  resultResponse = new ResultResponse();
        resultResponse.setCode(ResponseCode.ERROR.getCode());
        resultResponse.setMsg(msg);
        resultResponse.setData(data);
        return resultResponse;
    }

    public static ResultResponse ofFail(Integer code,String msg,Object data){
        ResultResponse  resultResponse = new ResultResponse();
        resultResponse.setCode(ResponseCode.ERROR.getCode());
        resultResponse.setMsg(msg);
        resultResponse.setData(data);
        return resultResponse;
    }

}
